package org.tc.feign.storefront;

import org.gdtc.storefront.entity.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.tc.feign.service.FeignStorefrontService;

import java.util.List;

@RestController
@RequestMapping("/Storefront")
@CrossOrigin(origins = {"*"}, methods = {RequestMethod.GET, RequestMethod.POST}, allowCredentials = "true")
public class FeignStorefrontController {

    @Autowired
    private FeignStorefrontService feignStorefrontService;


    /**
     * 公告查询模块
     *
     * @return
     */
    @RequestMapping("/selectAll")
    @ResponseBody
    public List<Notice> QueryNotice() {
        List list = feignStorefrontService.selectAll();
        return list;
    }


    /**
     * 公告删除模块
     *
     * @param id 公告ID
     * @return
     */
    @RequestMapping("/DeleByIdNotice")
    @ResponseBody
    public int DeleByIdNotice(@RequestBody Integer id) {
        int count = feignStorefrontService.deleteByPrimaryKey(id);
        return count;
    }

    /**
     * 公告添加模块
     *
     * @param notice 传入notice实体类
     * @return
     */
    @RequestMapping("/insert")
    @ResponseBody
    public int InsNotice(@RequestBody Notice notice) {
        int count = feignStorefrontService.insert(notice);
        return count;
    }

    /**
     * 公告修改模块
     *
     * @param notice 传入对象
     * @return
     */
    @RequestMapping("/updateNotice")
    @ResponseBody
    public int updateNotice(@RequestBody Notice notice) {
        int count = feignStorefrontService.updateByPrimaryKey(notice);
        return count;
    }
}
